package com.witdata.controller.log;

import com.witdata.common.domain.Result;
import com.witdata.common.domain.Status;
import com.witdata.common.domain.dto.LogDto;
import com.witdata.common.domain.vo.VisitTimesVo;
import com.witdata.common.service.LogService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("/log")
public class LogController {
    private final LogService logService;

    @PostMapping("/create")
    public Result<String> createLog(@RequestBody LogDto logDto) {
        logService.createLog(logDto);
        return Result.ok(Status.LogSaveSuccess);
    }

    @GetMapping("/list")
    public Result<List<LogDto>> getLogDtoList() {
        List<LogDto> logDtoList = logService.getLogDtoList();
        return Result.ok(Status.SUCCESS, logDtoList);
    }

    @GetMapping("/visit/timestamp")
    public Result<VisitTimesVo> getVisitTimestamp() {
        VisitTimesVo visitTimestamp = logService.getVisitTimestamp();
        return Result.ok(Status.SUCCESS, visitTimestamp);
    }

    @GetMapping("/visit/count")
    public Result<Long> getVisitCount() {
        Long visitCount = logService.getVisitCount();
        return Result.ok(Status.SUCCESS, visitCount);
    }

}
